<?php

class Application_Form_ArticleCategory extends Zend_Form
{
    private $view;
    
    public function init()
    {
         $this->view = Zend_Layout::getMvcInstance()->getView();
         $this->setAttrib("id","form-cat");
        
        /* ---------------------------------Begin detail group--------------------------------------------------- */
        //create element idcategories
        $idcategories = $this->createElement("hidden","idcategories");
        $idcategories->setDecorators(array("ViewHelper"));
        $this->addElement($idcategories);
        
        //create element category_name
        $category_name = $this->createElement("text","category_name");
        $category_name->setLabel("Tên danh mục")
                      ->setRequired() 
                      ->addValidators(array(
                            array("NotEmpty",false,array("messages"=>array('isEmpty'=>"Tên danh mục không để trống."))),
                      ))
                      ->setAttrib("size","50");
       $this->addElement($category_name);
       
        //create element admin_name
       $admin_name = $this->createElement("text","admin_name");
       $admin_name->setLabel("Tên danh mục (quản trị)")
                  ->setAttrib("size","50")
                  ->setDescription("Nếu sử dụng chung tên danh mục thì bỏ trống phần danh mục (quản trị)");
       $this->addElement($admin_name);
       
       // create element parent_id
       $parent_id = $this->createElement("select","parent_id");
       $parent_id->setLabel("Danh mục cha");
       $this->addElement($parent_id);
       
       // create element has_child
       $has_child = $this->createElement("radio","has_child");
       $has_child->setLabel("Có danh mục con?")
                 ->setMultiOptions(array(
                    '1'=>"Có",
                    '0'=>"Không"
                 ))->setOptions(array('separator'=>""))
                 ->setValue(0)
                 ->setAttrib("class","fancy-radio");
       $this->addElement($has_child);
       
       // create element sub_add
       $sub_add = $this->createElement("checkbox","sub_add");
       $sub_add->setLabel("Thêm")
               ->setAttrib("class","fancy-checkbox")
               ->setValue(true);
       $this->addElement($sub_add);
       
       // create element sub_del
       $sub_del = $this->createElement("checkbox","sub_del");
       $sub_del->setLabel("Xóa")
               ->setAttrib("class","fancy-checkbox")
               ->setValue(true);
       $this->addElement($sub_del);
       
       // create element sub_update
       $sub_update = $this->createElement("checkbox","sub_update");
       $sub_update->setLabel("Sửa")
               ->setAttrib("class","fancy-checkbox")
               ->setValue(true);
       $this->addElement($sub_update);
       
       // create group
       $this->addDisplayGroup(array(
            $idcategories,
            $category_name,
            $admin_name,
            $parent_id,
            $has_child,
            $sub_add,
            $sub_del,
            $sub_update
       ),"detail",array('class'=>'display-group'));
       
       
       /*-----------------------------Begin group 1-------------------------------*/
        // create element has_description
       $has_description = $this->createElement("radio","has_description");
       $has_description->setLabel("Giới thiệu")
                       ->setMultiOptions(array(
                        '1'=>"Có",
                        '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(0)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($has_description);
        
        // create element has_content
       $has_content = $this->createElement("radio","has_content");
       $has_content->setLabel("Nội dung")
                       ->setMultiOptions(array(
                        '1'=>"Có",
                        '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(0)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($has_content);
       
        // create element has_link
       $has_link = $this->createElement("radio","has_link");
       $has_link->setLabel("Có link")
                       ->setMultiOptions(array(
                        '1'=>"Có",
                        '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(0)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($has_link);
       
        // create element has_youtube
       $has_youtube = $this->createElement("radio","has_youtube");
       $has_youtube->setLabel("Có link Youtube")
                       ->setMultiOptions(array(
                        '1'=>"Có",
                        '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(0)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($has_youtube);
       
       // create element has_image
       $has_image = $this->createElement("radio","has_image");
       $has_image->setLabel("Có hình ảnh")
                       ->setMultiOptions(array(
                        '1'=>"Có",
                        '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(0)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($has_image);
       
       
        //create element image_w
       $image_w = $this->createElement("text","image_w");
       $image_w->setLabel("|| width")
                  ->setAttrib("size","3")
                  ->setDescription("px");
       $this->addElement($image_w);
       
       //create element image_h
       $image_h = $this->createElement("text","image_h");
       $image_h->setLabel("height")
                  ->setAttrib("size","3")
                  ->setDescription("px");
       $this->addElement($image_h);
       
       // create element has_crawler
       $has_crawler= $this->createElement("radio","has_crawler");
       $has_crawler->setLabel("Có nguồn tin")
                       ->setMultiOptions(array(
                            '1'=>"Có",
                            '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(0)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($has_crawler);       
       
       // create element has_tags
       $has_tags= $this->createElement("radio","has_tags");
       $has_tags->setLabel("Có tags")
                       ->setMultiOptions(array(
                            '1'=>"Có",
                            '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(0)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($has_tags);
       
       // create group
       $this->addDisplayGroup(array(
            $has_description,
            $has_content,
            $has_link,
            $has_youtube,
            $has_image,
            $image_w,
            $image_h,            
            $has_crawler,            
            $has_tags
       ),"groupleft",array('class'=>'display-group'));
       
       
       /*---------------------------------Begin group right-------------------------------------------*/
       // create element choice_multi
       $choice_multi= $this->createElement("radio","choice_multi");
       $choice_multi->setLabel("Hiển thị nhiều")
                       ->setMultiOptions(array(
                            '1'=>"Có",
                            '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(0)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($choice_multi);
       
       // create element choice_once
       $choice_once= $this->createElement("radio","choice_once");
       $choice_once->setLabel("Hiển thị một")
                       ->setMultiOptions(array(
                            '1'=>"Có",
                            '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(0)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($choice_once);
       
        // create element allow_add
       $allow_add= $this->createElement("radio","allow_add");
       $allow_add->setLabel("Cho phép thêm")
                       ->setMultiOptions(array(
                            '1'=>"Có",
                            '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(1)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($allow_add);
       
        // create element allow_del
       $allow_del= $this->createElement("radio","allow_del");
       $allow_del->setLabel("Cho phép xóa")
                       ->setMultiOptions(array(
                            '1'=>"Có",
                            '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(1)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($allow_del);
       
       // create element allow_update
       $allow_update= $this->createElement("radio","allow_update");
       $allow_update->setLabel("Cho phép cập nhật")
                       ->setMultiOptions(array(
                            '1'=>"Có",
                            '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(1)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($allow_update);
       
       // create element has_album
       $has_album = $this->createElement("radio","has_album");
       $has_album->setLabel("Có Album ảnh")
                       ->setMultiOptions(array(
                            '1'=>"Có",
                            '0'=>"Không"
                       ))->setOptions(array('separator'=>""))
                        ->setValue(0)
                        ->setAttrib("class","fancy-radio");
       $this->addElement($has_album);
       
       
        //create element album_w
       $album_w = $this->createElement("text","album_w");
       $album_w->setLabel("|| width")
                  ->setAttrib("size","3")
                  ->setDescription("px");
       $this->addElement($album_w);       
       
       //create element album_h
       $album_h = $this->createElement("text","album_h");
       $album_h->setLabel("height")
                  ->setAttrib("size","3")
                  ->setDescription("px");
       $this->addElement($album_h);
       
       // create group
       $this->addDisplayGroup(array(
            $choice_multi,
            $choice_once,
            $allow_add,
            $allow_del,
            $allow_update,
            $has_album,
            $album_w,
            $album_h
       ),"groupright",array('class'=>'display-group'));
       
       /*------------------------Begin group button------------------------------------*/
        // create submit button
        $submit = $this->createElement("submit","submit");
        $submit->setLabel("Thêm mới")
               ->setAttrib("class","btn btn-black");
        $this->addElement($submit);
        
        // create submit button
        $link = $this->view->url(array(
            'module'=>"admin",
            'controller'=>"article-category",
            'action'=>"list"
        ));
        $cancel = $this->createElement("button","cancel");
        $cancel->setLabel("Quay lại")
               ->setAttrib("class","btn btn-red")
               ->setAttrib("onclick","window.location='$link'");
        $this->addElement($cancel);  
    }


}
